package com.jingbian.cppccbackend.controller.user;


import com.github.pagehelper.PageInfo;
import com.jingbian.cppccbackend.entity.Meetings;
import com.jingbian.cppccbackend.entity.Result;
import com.jingbian.cppccbackend.entity.dto.MeetingsNeedDTO;
import com.jingbian.cppccbackend.service.user.IMeetingsService;
import com.jingbian.cppccbackend.utils.ResultUtil;
import com.jingbian.cppccbackend.vo.MeetingDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 会议表，用于存储会议基本信息 前端控制器
 * </p>
 *
 * @author pum
 * @since 2025-03-04
 */
@RestController
@RequestMapping("/users/meetings")
public class MeetingsController {
   @Autowired
   private IMeetingsService meetingsService;

  /**
   * 获取用户所需要参与的会议列表
   * @param meetingsNeedDTO
   * @return
   */
   @PostMapping("/list")
   private Result<PageInfo<Meetings>> needList(@RequestBody MeetingsNeedDTO meetingsNeedDTO) {
       return ResultUtil.success(meetingsService.getNeedList(meetingsNeedDTO));
   }

    @PostMapping("/list2")
    private Result<PageInfo<Meetings>> needList2(@RequestBody MeetingsNeedDTO meetingsNeedDTO) {
        return ResultUtil.success(meetingsService.getNeedList2(meetingsNeedDTO));
    }


    /**
   * 获取某一所需参与会议详情 -- 用户进行查看
   * @param mid
   * return
   */
  @GetMapping("/detail/{mid}")
  private Result<MeetingDetailVO> meetDetail(@PathVariable Integer mid) {
    return ResultUtil.success(meetingsService.getDetail(mid));
  }

  /**
   *  提交无法签到理由 -- 不影响实际签到
   * @param mid
   * @param reason
   * @return
   */
  @PutMapping("/submitReason")
  private Result<MeetingDetailVO> submitReason(Integer mid,String reason) {
    return ResultUtil.success(meetingsService.submitReason(mid,reason));
  }

  /**
   * 用户进行签到 --待进行定位功能
   * @param mid
   * @return
   */
  @PutMapping("/sign/{mid}")
  private Result<String> sign(@PathVariable Integer mid) {
    meetingsService.sign(mid);
    return ResultUtil.success("签到成功！");
  }

}
